set -eux

# Add Docker's official GPG key:
mv /etc/apt/sources.list.d/yarn.list /etc/apt/sources.list.d/yarn.list.bak

apt update

apt install -y \
    docker-ce-cli docker-compose-plugin \
    bash-completion \
    gettext \
    iputils-ping \
    vim \
    sqlite3 \
    dnsutils \
    protobuf-compiler

# go
go env -w GO111MODULE=on \
    && go env -w GOPROXY='http://goproxy.wh.io.plus,https://goproxy.cn,direct'

go install mvdan.cc/gofumpt@v0.7.0
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.35.2
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.5.1

# install kubectl
wget -O kubectl http://mirror.wh.io.plus/k8s_deps/kubectl

install -m 755 ./kubectl /usr/bin/kubectl

rm -rf ./kubectl

# 安装buildctl
mkdir -p /install
cd /install

version='v0.17.1'
tar_file="buildkit-${version}.linux-amd64.tar.gz"

wget http://mirror.wh.io.plus/buildkit/${tar_file} \
    -O ${tar_file}

tar -xvf ${tar_file}

install --mode 555 bin/* /usr/bin/

rm -rf /install/*

# shfmt
wget -O /usr/local/bin/shfmt http://mirror.wh.io.plus/dev_deps/shfmt_v3.6.0_linux_amd64
chmod +x /usr/local/bin/shfmt

# extend shell
echo '
source /root/.bashrc-extend-ips.sh
' >>~/.bashrc
source ~/.bashrc
